﻿<UserControl x:Class="Jamcast.Plugins.Spotify.UI.View.LoggedOutView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             mc:Ignorable="d"
             d:DesignHeight="400" d:DesignWidth="800">
    <StackPanel HorizontalAlignment="Left" Orientation="Vertical" Width="550">
        <TextBlock Margin="0 16 0 0" TextWrapping="Wrap" FontSize="16">You need to be a Spotify Premium subscriber to enable this channel. Please log in.</TextBlock>
        <TextBlock FontSize="15" Text="{Binding LoginError}" Foreground="Red" Margin="0 8 0 0" TextWrapping="Wrap" />
        <Grid HorizontalAlignment="Left" Margin="0 8 0 0" Width="300">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
                <RowDefinition Height="Auto" />
            </Grid.RowDefinitions>
            <Label Content="Username:" Grid.Row="0" HorizontalAlignment="Stretch" />
            <TextBox Margin="0 2 0 0" Text="{Binding EmailOrUsername, Mode=TwoWay}" Grid.Row="1">
                <TextBox.Style>
                    <Style TargetType="TextBox" BasedOn="{StaticResource {x:Type TextBox}}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsLoggingIn}" Value="true">
                                <Setter Property="IsEnabled" Value="False" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </TextBox.Style>
            </TextBox>
            <Label Margin="0 8 0 0" Content="Password:" Grid.Row="2" />
            <PasswordBox Margin="0 2 0 0" Name="txtPassword" Grid.Row="3" KeyDown="txtPassword_KeyDown">
                <PasswordBox.Style>
                    <Style TargetType="PasswordBox" BasedOn="{StaticResource {x:Type PasswordBox}}">
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsLoggingIn}" Value="true">
                                <Setter Property="IsEnabled" Value="False" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </PasswordBox.Style>
            </PasswordBox>
            <DockPanel Margin="0 8 0 0" Grid.Row="5" HorizontalAlignment="Stretch" LastChildFill="True">
                <Label Content="Application Key:" DockPanel.Dock="Left" />
                <ContentPresenter Margin="0 0 8 0">
                    <ContentPresenter.Style>
                        <Style TargetType="ContentPresenter">
                            <Setter Property="Content">
                                <Setter.Value>
                                    <Button HorizontalAlignment="Right" Content="Load" Command="{Binding LoadApplicationKeyCommand}" />
                                </Setter.Value>
                            </Setter>
                            <Style.Triggers>
                                <DataTrigger Binding="{Binding IsApplicationKeyLoaded}" Value="True">
                                    <Setter Property="Content">
                                        <Setter.Value>
                                            <Label HorizontalAlignment="Right" Content="Loaded!" />
                                        </Setter.Value>
                                    </Setter>
                                </DataTrigger>
                            </Style.Triggers>
                        </Style>
                    </ContentPresenter.Style>
                </ContentPresenter>
            </DockPanel>
            <Button HorizontalAlignment="Left" Margin="0 24 0 0" Content="Log In" Width="90" Grid.Row="6" Command="{Binding LogInCommand}" CommandParameter="{Binding ElementName=txtPassword}">
                <Button.Style>
                    <Style TargetType="Button" BasedOn="{StaticResource {x:Type Button}}">
                        <Setter Property="IsEnabled" Value="True" />
                        <Style.Triggers>
                            <DataTrigger Binding="{Binding IsLoggingIn}" Value="true">
                                <Setter Property="IsEnabled" Value="False" />
                            </DataTrigger>
                        </Style.Triggers>
                    </Style>
                </Button.Style>
            </Button>
        </Grid>
    </StackPanel>
</UserControl>